home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6968 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  43 lines

  1. Path: sun001.spd.dsccc.com!spd!jmccarty
  2. From: jmccarty@spd.dsccc.com (Mike McCarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: MACROS with varying number of parameters
  5. Date: 16 Feb 1996 20:02:05 GMT
  6. Organization: DSC Communications Corporation, Plano, Texas USA
  7. Message-ID: <4g2nrt$l6h@sun001.spd.dsccc.com>
  8. References: <freedmanj-1502961337370001@155.95.68.41>
  9. NNTP-Posting-Host: aplo139.spd.dsccc.com
  10.  
  11. In article <freedmanj-1502961337370001@155.95.68.41>,
  12. Jerry Freedman <freedmanj@mail.ndhm.gtegsc.com> wrote:
  13. )
  14. )   A while back I saw a trick for writing macros with a variable number of
  15. )paramters. Its very useful for debugging stuff like
  16. )
  17. )#ifdef
  18. )#define DEBUG_PRINT(some parameters) printf(parameters)
  19. )#else
  20. )#define DEBUG_PRINT(some_parameters) 
  21. )#endif
  22. )
  23. )   Unfortunately, I lost it. I'd like to see it again,
  24. )
  25. )
  26. )                    Thanks
  27. )                Jerry Freedman,Jr
  28.  
  29.  
  30. #ifdef DEBUGGING_ON
  31. #define DEBUG_PRINT(x)    printf x
  32. #else
  33. #define DEBUG_PRINT(x)
  34. #endif
  35.  
  36.     DEBUG_PRINT(("This is a format string: %s\n",string));
  37.  
  38. Mike
  39. ----
  40. char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
  41.  
  42. I don't speak for DSC.         <- They make me say that.
  43.